var ctxPath = "/education";

!function ($) {
    var orderCode = $.getUrlParam('orderCode');
    var phone;
    /**
     * 初始化游学产品详情方法
     * @param id
     */
    var initPROrderDetail = function(orderCode) {
        $.ajax({
            url: ctxPath + '/wx/api/pointReward/getPROrderByCode',
            type: 'post',
            dataType: 'json',
            data: {orderCode: orderCode},
            success: function (result) {
                if(result.returnCode == 0) {

                    $("#orderCode").html("订单编号: " + result.orderCode);
                    $("#name").html(result.name);

                    $("#customerName").html("客户名称: " + result.customerName);
                    $("#phone").html("联系方式: " + result.phone);
                    $("#address").html("收货地址: " + result.address);
                    phone = result.phone;
                    $(".amount").html(result.amount);

                    $(".list-price").html("<em>¥</em>" + result.totalPrice);

                    $("#prImage").attr("src", result.prImage);

                } else {
                    alert(result.returnMsg);
                }
            }
        });
    };

    initPROrderDetail(orderCode);

    $("#payBtn").click(function () {
        $.ajax({
            url: ctxPath + '/wx/api/pointReward/payOrder',
            type: 'post',
            dataType: 'json',
            data: {orderCode: orderCode},
            success: function (result) {
                if(result.returnCode == 0) {
                    alert("支付成功，等待系统发货")
                    window.location.href = "/education/wx/integralOrders.html";
                } else {
                    alert(result.returnMsg);
                }
            }
        });
    });
}(jQuery);